using UnityEngine;
using System.Collections;

public class ConnectPerso : MonoBehaviour {
	
	public GameObject target;
	public Transform Posicao;
	public string IP = "127.0.0.1";
	public int Port = 25001;	
	
	void OnGUI(){
					
		if(Network.peerType == NetworkPeerType.Disconnected){
			/*if(GUI.Button(new Rect(100,100,100,25),"Start Cliente")){
				Debug.Log(IP + " " + Port);
				Network.Connect(IP,Port);
				Debug.Log("Conectou");
				networkView.RPC("InstaciaPerso", RPCMode.All);
			};	*/
		}else{
			if(Network.peerType == NetworkPeerType.Client){
				if(GUI.Button(new Rect(100,175,110,25), "Logout")){
						Network.Disconnect(250);
				}	
			}
		}
	}
		/*
	[RPC]
	void InstaciaPerso(){
		
	}*/
	
	void OnNetworkLoadedLevel () {
			Network.Instantiate(target, new Vector3(Posicao.position.x,Posicao.position.y,
													   Posicao.position.z), Quaternion.identity, 0);	
	}
}
